package com.jinzecloud.reportapproval.utils;

import cn.hutool.core.io.FileUtil;
import com.documents4j.api.DocumentType;
import com.documents4j.api.IConverter;
import com.documents4j.job.LocalConverter;

import java.io.File;

public class PDFUtil {

    public static File WordToPdf(File wordFile, File pdfFile) {
        File outputStream = FileUtil.touch(pdfFile);
        IConverter converter = LocalConverter.builder().build();
        converter.convert(FileUtil.getInputStream(wordFile)).as(DocumentType.DOCX).to(outputStream).as(DocumentType.PDF).execute();
        return pdfFile;
    }

}
